<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //数组去重 ['c', 'a', 'z', 'a', 'x', 'a', 'x', 'c', 'b']
        //    遍历旧盒子中的元素，创建一个新盒子，在新盒子里面索引，如果有就不存，没有就存进去
        function unique(arr) {
            //var arr1 = ['c', 'a', 'z', 'a', 'x', 'a', 'x', 'c', 'b'];
            var arr2 = [];
            for (var i = 0; i < arr.length; i++) {
                if (arr2.indexOf(arr[i]) === -1) {
                    arr2.push(arr[i]);
                }
            }
            return arr2;
        }
        var col = unique(['c', 'a', 'z', 'a', 'x', 'a', 'x', 'c', 'b']);
        console.log(col);
    </script>
</head>

<body>

</body>

</html>